syntax = "proto3";

package kumactl.config.v1alpha1;

option go_package = "github.com/kumahq/kuma/config/v1alpha1";

import "validate/validate.proto";

// Configuration defines configuration of `kumactl`.
message Configuration {

  // List of known Control Planes.
  repeated ControlPlane control_planes = 1;

  // List of configured `kumactl` contexts.
  repeated Context contexts = 2;

  // Name of the context to use by default.
  string current_context = 3;
}

// ControlPlane defines a Control Plane.
message ControlPlane {

  // Name defines a reference name for a given Control Plane.
  string name = 1 [ (validate.rules).string.min_len = 1 ];

  // Coordinates defines coordinates of a given Control Plane.
  ControlPlaneCoordinates coordinates = 2
      [ (validate.rules).message.required = true ];
}

// ControlPlaneCoordinates defines coordinates of a Control Plane.
message ControlPlaneCoordinates {
  message Headers {
    string key = 1;
    string value = 2;
  }
  message ApiServer {

    // URL defines URL of the Control Plane API Server.
    string url = 1 [ (validate.rules).string.uri = true ];

    // CaCert defines the certificate authority which will be used to verify
    // connection to the control plane API server
    string ca_cert_file = 2;

    // ClientCert defines the certificate of the authorized client of the
    // control plane API server
    string client_cert_file = 3;

    // ClientKey defines the key of the authorized client of the control plane
    // API server
    string client_key_file = 4;

    // Headers to be added for communication with Kuma control plane
    repeated Headers headers = 5;

    // Authentication type
    string auth_type = 6;

    // Authentication configuration for defined authentication type
    map<string, string> auth_conf = 7;
  }

  ApiServer api_server = 1 [ (validate.rules).message.required = true ];
}

// Context defines a context in which individual `kumactl` commands run.
message Context {

  // Name defines a reference name for a given context.
  string name = 1 [ (validate.rules).string.min_len = 1 ];

  // ControlPlane defines a reference to a known Control Plane.
  string control_plane = 2 [ (validate.rules).string.min_len = 1 ];

  // Defaults defines default settings for a context.
  message Defaults {

    // Mesh defines a Mesh to use in requests if one is not provided explicitly.
    string mesh = 1;
  }

  // Defaults defines default settings for a given context.
  Defaults defaults = 3;
}
